<extend name="public@base5"/>
<block name="head">
    <include file="theme/functions"/>
</block>
<block name="main">
    <div class="wrap">
        <div class="position-relative">
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a class="nav-link"
                       href="{:url('Theme/fileSetting',['file'=>$fileName,'theme'=>$theme,'tab'=>'widget'])}">
                        {:lang('Widget')}
                    </a>
                </li>
                <notempty name="file.more.vars">
                    <li class="nav-item">
                        <a class="nav-link active"
                           href="{:url('Theme/fileSetting',['file'=>$fileName,'theme'=>$theme,'tab'=>'var'])}">
                            {:lang('SETTING')}
                        </a>
                    </li>
                </notempty>
                <notempty name="has_public_var">
                    <li class="nav-item">
                        <a class="nav-link"
                           href="{:url('Theme/fileSetting',['file'=>$fileName,'theme'=>$theme,'tab'=>'public_var'])}">
                            {:lang('Global Settings')}
                        </a>
                    </li>
                </notempty>
            </ul>
        </div>

        <form method="post" class="js-ajax-form  margin-top-20" action="admin/theme/{$theme}/file/setting">
            <notempty name="file['more']['vars']">
                {:_parse_vars($file.more.vars,'files['.$file['id'].'][vars]')}
                <else/>
            </notempty>
            <div style="display: none;">
                <input type="hidden" name="admin_content_lang" value="{:cmf_current_home_lang()}"/>
                <button type="submit" class="btn btn-primary js-ajax-submit" id="submit-btn"
                        data-success="successCallback">
                    <i class="fa fa-save fa-fw"></i> {:lang('SAVE')}
                </button>
            </div>
        </form>
    </div>
</block>
<block name="scripts">
    <include file="theme/scripts"/>
    <script>
        function successCallback(data, statusText, xhr, $form) {
            function _refresh() {
                if (data.url) {
                    //返回带跳转地址
                    window.location.href = data.url;
                } else {
                    if (data.code == 1) {
                        //刷新当前页
                        reloadPage(window);
                    }
                }
            }

            noty({
                text: data.msg,
                type: 'success',
                layout: 'topCenter',
                modal: true,
                // animation: {
                //     open: 'animated bounceInDown', // Animate.css class names
                //     close: 'animated bounceOutUp', // Animate.css class names
                // },
                timeout: 800,
                callback: {
                    afterClose: function () {
                        if (parent.afterSaveSetting) {
                            parent.afterSaveSetting();
                        }
                        _refresh();
                    }
                }
            });
        }
    </script>
</block>

